<div id="jxIndexDiv" style="width:100%;height:100%;">
    <div class="easyui-panel" title="" data-options="fit:true,border:false">
        <div class="easyui-layout" data-options="fit:true">
            <!--中间-->
            <div data-options="region:'center'" >
                <!--中间布局-->
                    <div class="easyui-layout"  data-options="fit:true">
                        <div data-options="region:'west'" title="岗位信息" style="width: 30%" >
                            <!--岗位信息表-->
                            <table id="jxIndexDatagridPost"  style="width: 100%"></table>
                            <!--员工信息表-按钮-->
                            <div id="jxIndexDivTreegridEmpBtn" style="display: none">
                                <a href="#" class="easyui-linkbutton c2" data-options="plain:true"> <span class="fa fa-plus-square fa-fw"></span>添加</a>
                                <a href="#" class="easyui-linkbutton c4" data-options="plain:true"> <span class="fa fa-floppy-o fa-fw"></span>保存</a>
                                <a href="#" class="easyui-linkbutton c3" data-options="plain:true"> <span class="fa fa-minus-square fa-fw"></span>删除</a>
                            </div>
                        </div>
                        <div data-options="region:'center'" title="考核内容">
                            <table id="jxIndexAssessContent"  style="width: 100%"></table>
                        </div>
                        <div data-options="region:'south'" title="生产部绩效考核统计表" style="height:70%">
                            <div id="jxIndexContent" class="easyui-panel" fit="true" >
                            </div>
                        </div>
                    </div>
            </div>
        </div>
    </div>
    <!--引入绩效考核项目的全局变量-->
    <script src="/js/jxAssess/jxAssessGlobalVariable.js"></script>
    <script src="/js/jxAssess/jxAssessGlobalFunction.js"></script>
    <script th:inline="none">
        // //刷新部门
        // $("#jxIndexDivTreegridPkDept").treegrid({
        //     idField: 'id',
        //     treeField: 'text',
        //     data: [{"id":OSG_HUIZHOU_CODE,"text":OSG_HUIZHOU_NAME,state:'closed'}, {"id":OSG_ZHAOTING_CODE,"text":OSG_ZHAOTING_NAME,state:'closed'}],
        //     columns: [[
        //         {title: 'id', field: 'id', checkbox:true},
        //         {title: '组织架构', field: 'text', width: '96.5%'}
        //     ]],
        //     onBeforeExpand:function (node) { //tree树的事件，点击三角符号下拉触发此事件
        //         // 异步加载子节点的方法（就是那么简单下面一句话即可）；easyui内部有判定加载完一次就不会重复去后台获取，
        //         $(this).treegrid('options').url='/jxIndex/getDeptByPkOrg?pkOrg='+node.id;
        //     },onClickRow:function (row) { //用户点击节点的时候后触发
        //        // var pkFatherorg = row.pkFatherorg; //上级元部门:根（组织）不会有此字段，最顶层的部门是"~"
        //         var children=row.children; //叶子节点是空数组：[]
        //        // console.log(row)
        //         if (children){
        //             if (children.length<=0){  //根（组织）不会有此字段，
        //                 //根据部门id，获取本部门的人员信息
        //                 currentDept=row.id;  //部门字段pk_dept值
        //
        //             }
        //         }
        //     }
        // })
        window.pzcj_currentDept="1002O110000000000MMB"
        $("#jxIndexDatagridPost").datagrid({
            striped:true,
            nowrap:false,
            singleSelect:true,
            fitColumns: true,
            scrollbarSize:0,  //最右侧多出来的去除
            url:"/jxIndex/getPostByDept?pkDept="+pzcj_currentDept,
            //toolbar:"#jxIndexDivTreegridEmpBtn",
            columns: [[
                {title: 'id', field: 'id', checkbox:true,align:'center'},
                {title: '岗位名称', field: 'name', width: '20%',align:'center'},
                {title: '部门', field: 'pkDeptName', width: '33%',align:'center'},
                {title: '说明', field: 'describe', width: '38%',align:'center'}
            ]],
            onClickRow:function (index, row) {
                //console.log(index)
                // console.log(row)
                //获取职位
                var postId=row.id;
                //岗位名称
                var postName = row.name;
                if (postId){
                    //考核内容：根据岗位和部门刷出数据
                    $("#jxIndexAssessContent").datagrid({
                        striped:true,
                        nowrap:false,
                        rownumbers:true,
                        fitColumns: true,
                        scrollbarSize:0,  //最右侧多出来的去除
                        url:"/jxIndex/getAssessContentData",
                        queryParams:{
                            postId: postId,
                            pkDept:pzcj_currentDept
                        },
                        //toolbar:"#jxIndexDivTreegridEmpBtn",
                        columns: [[
                            {title: '项目<br>编码', field: 'code', width: '8%',align:'center',"hidden": "true"},
                            {title: '考核名称', field: 'name', width: '21%',align:'center'},
                            {title: '结果', field: 'bonus', width: '8%',align:'center'},
                            {title: '说明', field: 'explains', width: '70%',align:'center'},
                            //{title: '备注', field: 'remark', width: '37%',align:'center'},

                        ]],
                        groupField:'code',
                        view: groupview,    //视图是第三方的
                        groupFormatter:function(value, rows){
                            //console.log("考核内容：",rows)
                            return rows[0].nameCondition;
                        },
                        groupStyler: function(value,rows){
                            return 'background-color:#E1FFFF;color:#228B22;'; // return inline style
                        },
                        onLoadSuccess:function(data){//若你需要页面在打开时所有分组默认是折叠状态,加上这句代码
                            $('#jxIndexAssessContent').datagrid('collapseGroup'); //collapseGroup 折叠一个分组
                        }
                    })
                    //清空考核详情页面
                    //根据岗位条件刷出不同的考核详情页面
                    updateByExample(postName,pzcj_currentDept,row)
                }
            }
        })

        //考核详情内容初始化----panel
        function updateByExample(postName,pzcj_currentDept,row) {
            //默认老开料员
            switch (postName) {
                case window.JX_PZCJ_KAILIAOYUAN:
               var  urlPath="/jx/jxAssess/pzcj/peiZhiCheJian_kailiaoyuan.html";
                    openJxAssessTable(postName,"peiZhiCheJianKaiLiaoYuan",urlPath,pzcj_currentDept)
                    break;
                case window.JX_PZCJ_NEWKAILIAOYUAN://新开料员
                    urlPath="/jx/jxAssess/pzcj/peiZhiCheJian_newkailiaoyuan.html";
                    openJxAssessTable(postName,"peiZhiCheJianNewKaiLiaoYuan",urlPath,pzcj_currentDept)
                    break;
                case window.JX_PZCJ_KAILIAOGUANLIRENYUAN:
                    urlPath="/jx/jxAssess/pzcj/peiZhiCheJian_manager.html";
                    openJxAssessTable(postName,"peiZhiCheJianManager",urlPath,pzcj_currentDept)
                    break;
                case window.JX_PZCJ_FUZHURENYUAN:
                    urlPath="/jx/jxAssess/pzcj/peiZhiCheJian_fuzhurenyuan.html";
                    openJxAssessTable(postName,"peiZhiCheJianFuZhuRenYuan",urlPath,pzcj_currentDept)
                    break;
                case window.JX_PZCJ_PEIXUNZUZHANG:
                    urlPath="/jx/jxAssess/pzcj/peiZhiCheJian_peiXunZuZhang.html";
                    openJxAssessTable(postName,"peiZhiCheJianManager",urlPath,pzcj_currentDept)
                    break;
                case window.JX_PZCJ_CHENGLIAOZHUGUAN:
                    urlPath="/jx/jxAssess/pzcj/peiZhiCheJian_chenLiaoZhuGuan.html";
                    openJxAssessTable(postName,"peiZhiCheJianChengLiao",urlPath,pzcj_currentDept)
                    break;
            }
        }

        function openJxAssessTable(postName,t,urlPath,pzcj_currentDept) {
            $('#jxIndexContent').panel({
                fit:true,
                href:urlPath,
                onLoad:function () {
                    var date=new Date();
                    var month = date.getMonth()+1;
                    var year=date.getFullYear();
                    addPZCJData(t,postName,pzcj_currentDept,year,month);
                }
            })
        }

    </script>

</div>